import axios from 'axios'

// 获取家庭成员
export function getFamily() {
  let url = '/users/family'
  return axios.get(url).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}
// 删除家庭成员
export function delFamily (id) {
  const url = '/users/delFamily'
  const param = {
    memberId: id
  }
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}

// 设为默认就诊人
export function setDefault (id) {
  const url = '/users/setDefault'
  const param = {
    memberId: id
  }
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}

// 修改就诊人
export function updateFamily (id, key, value) {
  const url = '/users/updateFamily'
  const param = {
    memberId: id,
    key: key,
    value: value
  }
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}

// 增加就诊人
export function addMember (param) {
  const url = '/users/addMember'
  return axios.post(url, param).then((res) => {
    return Promise.resolve(res)
  }).catch((err) => {
    console.log(err)
  })
}
